package cn.cosmosx.base.validate;

import javax.validation.ConstraintValidatorContext;

/**
 * 参数校验器基类
 * <p>
 * 可定制个性化消息模板
 *
 * @author gengzhy
 */
public abstract class AbstractValidator {

    /**
     * 禁用默认的消息模板
     *
     * @param message
     * @param context
     */
    protected void setTemplateMessage(String message, ConstraintValidatorContext context) {
        context.disableDefaultConstraintViolation();
        context.buildConstraintViolationWithTemplate(message).addConstraintViolation();
    }
}
